package com.lanswon.qzsmk.util;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.slf4j.LoggerFactory;

import com.lanswon.qzsmk.exception.SystemException;

import ch.qos.logback.classic.Logger;

public class HtmlParseUtil {
	
	private static Logger logger = (Logger) LoggerFactory
			.getLogger(HtmlParseUtil.class);

	public static void main(String[] args) throws IOException {
		parseHtml("http://192.168.0.12:9999/qzsmk/resource/makeCardFile/bank/JS_BANK/BP");
	}
	
	public static List<String> parseHtml(String url) {
		List<String> ll = new ArrayList<>();
//		String u ="http://192.168.0.12:9999/qzsmk/resource/unexcels";
		Document doc;
		try {
			doc = Jsoup.connect(url).get();
		
		String tagName = "a[href]";
		String property ="href";
		Iterator<Element> eles = doc.select(tagName).iterator();
		
		while(eles.hasNext()){
			Element ele = eles.next();
			String value = ele.attr(property);
			ll.add(value);
			System.out.println("file:"+value);
		}
		
		} catch (IOException e) {
			e.printStackTrace();
			 String msg1="IO流异常";
				logger.error(msg1);
				throw new SystemException(SystemException.IOException, msg1);

		}
		return ll;
		
	};
}
